package com.chanyachting.emall.action.hr;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.chanyachting.emall.domain.Company;
import com.chanyachting.emall.domain.Joblist;
import com.chanyachting.emall.form.CompanyForm;
import com.chanyachting.emall.service.CompanyService;
import com.chanyachting.emall.service.RecruitmentinformationService;
import com.chanyachting.emall.serviceImpl.CompanyServiceImpl;
import com.chanyachting.emall.serviceImpl.RecruitmentinformationServiceImpl;

public class QueryCompanyHrContentAction  extends Action{
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		CompanyService comService = new CompanyServiceImpl();
		RecruitmentinformationService rf = new RecruitmentinformationServiceImpl();
		Joblist tmpJ = null;
		Joblist jl = null;
		CompanyForm tForm = (CompanyForm)form;
		if(tForm.getId() == null || tForm.getJobId() == null || tForm.getRid() == null) {
			return mapping.findForward("error");
		}
		
		List<Company> alList = null;
		
		alList = comService.getCompanyById(tForm.getId().toString());
		if (alList.size() == 0) {
			return mapping.findForward("error");
		}
		
		tmpJ = new Joblist();
		
		tmpJ.setId(tForm.getId());
		jl = rf.getJobList(tForm.getRid(), tForm.getJobId());
		if (jl == null) {
			return mapping.findForward("error");
		}

		tForm.setJl(jl);
		tForm.setComp(alList.get(0));
		return mapping.findForward("readCompanyHrContent");
	}
}
